import {acceptHMRUpdate, defineStore} from 'pinia';

export const useGeneralStore = defineStore('general', {
  state: () => ({
    tokenInfo: {
      key: '',
      value: '',
    },
  }),
  getters: {
    isLogin() {
      return this.tokenInfo.value;
    },
  },
  actions: {
    setTokenInfo(key, value) {
      this.tokenInfo.key = key;
      this.tokenInfo.value = value;
    },
    logout() {
      this.tokenInfo = {};
    },
  },
  persist: true,
});

if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useGeneralStore, import.meta.hot));
}